package com.pudu.pudusclient;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;


public class MySocketPacket {
    private final MySocketPacket self = this;

    private static final AtomicInteger IDAtomic = new AtomicInteger();

    /* Constructors */
    public MySocketPacket(byte[] data, int ntype) {
        this.ID = IDAtomic.getAndIncrement();
        this.data = Arrays.copyOf(data, data.length);
        this.nType = ntype;
    }


    /* Public Methods */

    /* Properties */
    /**
     * ID, unique
     */
    private final int ID;
    public int getID() {
        return this.ID;
    }

    /**
     * int data
     */
    private final int nType;//0x01 beat heart; 0x02 data
    public int getType() {
        return this.nType;
    }

    /**
     * bytes data
     */
    private final byte[] data;
    public byte[] getData() {
        return this.data;
    }

    private boolean canceled;
    public MySocketPacket setCanceled(boolean canceled) {
        this.canceled = canceled;
        return this;
    }
    public boolean isCanceled() {
        return this.canceled;
    }

    private float sendingProgress;
    public MySocketPacket setSendingProgress(float sendingProgress) {
        this.sendingProgress = sendingProgress;
        return this;
    }
    public float getSendingProgress() {
        return this.sendingProgress;
    }
}